#include "radar.h"
#include <iostream>

void Radar::registerObserver(Observer* observer) {
    observers.push_back(observer);
}

void Radar::removeObserver(Observer* observer) {
    // 实现删除逻辑
}

void Radar::notifyObservers() {
    for (auto& obs : observers) {
        obs->update(obstacleStatus);
    }
}

void Radar::setObstacleStatus(int status) {
    switch (status) {
        case 1: obstacleStatus = "前方"; break;
        case 2: obstacleStatus = "左前方"; break;
        case 3: obstacleStatus = "右前方"; break;
        default: obstacleStatus = "未知";
    }
    notifyObservers();
}